package com.ctakit.sdk.app.util;

import android.app.Activity;

import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMWeb;

/**
 * 作者：LiangboXu on 2016/3/11 14:18
 * 邮箱：kingback011@163.com
 */
public class UmengShareUtils {

//    图片(url)
//
//    UMImage image = new UMImage(ShareActivity.this, "http://www.umeng.com/images/pic/social/integrated_3.png");
//
//    图片(本地资源引用)
//
//    UMImage image = new UMImage(ShareActivity.this,
//            BitmapFactory.decodeResource(getResources(), R.drawable.image));
//
//    图片(本地绝对路径)
//
//    UMImage image = new UMImage(ShareActivity.this,
//            BitmapFactory.decodeFile("/mnt/sdcard/icon.png")));


    public static void openUmengShare(Activity activity, String title, String text, String url, UMImage image,UMShareListener umShareListener) {

        final SHARE_MEDIA[] displaylist = new SHARE_MEDIA[]{
                SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE,SHARE_MEDIA.QQ
        };
        new ShareAction(activity).setDisplayList(displaylist)
                .withText(text)
                .withSubject(title)

                .withMedia(image)
                .setCallback(umShareListener)
//                .setListenerList(umShareListener, umShareListener)
//                .setShareboardclickCallback(shareBoardlistener)
                .open();

    }

    public static void shareSelfDefine(Activity activity, String title, String text, String url, UMImage image, SHARE_MEDIA share_media,UMShareListener umShareListener ) {
        UMWeb web = new UMWeb(url);
        web.setTitle(title);//标题
        web.setThumb(image);  //缩略图
        web.setDescription(text);//描述
        new ShareAction(activity)
                .setPlatform(share_media)
                .setCallback(umShareListener)
                .withMedia(web)
                .share();
    }

//     new UMShareListener() {
//        @Override
//        public void onResult(SHARE_MEDIA platform) {
//            Toast.makeText(ShareActivity.this, platform + " 分享成功啦", Toast.LENGTH_SHORT).show();
//        }
//
//        @Override
//        public void onError(SHARE_MEDIA platform, Throwable t) {
//            Toast.makeText(ShareActivity.this,platform + " 分享失败啦", Toast.LENGTH_SHORT).show();
//        }
//
//        @Override
//        public void onCancel(SHARE_MEDIA platform) {
//            Toast.makeText(ShareActivity.this,platform + " 分享取消了", Toast.LENGTH_SHORT).show();
//        }
//    };

}
